﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using Bzure.Common.Core;

namespace Bzure.Mvc.Controllers
{
    [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, AllowMultiple = true, Inherited = true)]
    public class MenuFlagFilter : FilterAttribute, IActionFilter
    {
        public string[] MenuFlag;
        public MenuFlagFilter(params  string[] menuFlags)
        {
            this.MenuFlag = menuFlags;
        }
        public void OnActionExecuted(ActionExecutedContext filterContext)
        {
            List<string> list = filterContext.Controller.ViewBag._bzureMvcMenuFlag;
            if (list.IsNullOrEmpty())
            {
                list = new List<string>();
                filterContext.Controller.ViewBag._bzureMvcMenuFlag = list;
            }
            list.AddRange(this.MenuFlag);
        }

        public void OnActionExecuting(ActionExecutingContext filterContext)
        {

        }
    }
}
